<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  Array.prototype.myMap = function(callback){
    let newArr = []
    for (let i = 0; i < this.length; i++) {
      let res =  callback(this[i],i,this)
        typeof  res === 'undefined'? newArr[i] = this[i] :newArr[i] = res
    }
     return newArr
  }

 let res =  [2,1,4,5,6].myMap(item =>{
   if (item >4) return item+1
 })
  console.log(res);

  console.log("---");
  console.log([2, 1, 4, 5, 6].map(ele => ele++));

</script>
</body>
</html>